package com.mz.mattress.admin.api.admin;

import com.mz.mattress.admin.service.SaleRatioConfigService;
import com.mz.mattress.api.common.Constants;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.SaleRatioConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

@Slf4j
@RestController
@RequestMapping(Constants.ADMIN_PATH + "saleRatioConfig")
public class SaleRatioConfigController {

    @Autowired
    private SaleRatioConfigService saleRatioConfigService;

    @GetMapping("/list")
    public Result<List<SaleRatioConfig>> list() {
        return saleRatioConfigService.list();
    }
    
    @GetMapping(value = "/{id}")
    public Result<SaleRatioConfig> detail(@PathVariable Integer id) {
        return saleRatioConfigService.getById(id);
    }

    @PostMapping
    public Result add(@RequestBody SaleRatioConfig saleRatioConfig) {
        return saleRatioConfigService.add(saleRatioConfig);
    }

    @PutMapping
    public Result update(@RequestBody SaleRatioConfig saleRatioConfig) {
        return saleRatioConfigService.updateById(saleRatioConfig);
    }

    @DeleteMapping
    public Result delete(@RequestBody Set<Integer> ids) {
        return saleRatioConfigService.deleteByIds(ids);
    }

}
